clear all 
set more off
*set maxvar 20000

cd "/Users/yasenov/Dropbox/ June 2016/Writeup/Economic Inquiry/EI R and R 2"
use "/Users/yasenov/Dropbox//data_dta/master.dta"

drop if substr(subject, 1, 2) == "it" | substr(subject, 1, 2) == "cs" 

tostring id grade year, replace
gen course = grade + " " + subject + " " + cohort
gen class = year + " " + course
gen studentxclass = id + " " + class
gen gradebook = year + grade + cohort
destring id grade year, replace

global controls order_ass num_month bulg

gen malelate = male*late_start
gen maleteachermale = male*teacher_male

eststo clear

eststo: xi: qui reg Zmarks male, vce(cluster class)
estadd local classfe " "
estadd local monthfe " "
estadd local controls " "  
eststo: xi: qui reg Zmarks male malelate maleteachermale teacher_male late_start, vce(cluster class)
estadd local classfe " "
estadd local monthfe " "
estadd local controls " "
eststo: xi: qui reg Zmarks male malelate maleteachermale teacher_male late_start i.month, vce(cluster class)
estadd local classfe " "
estadd local monthfe " X "
estadd local controls " "
eststo: xi: qui reg Zmarks male malelate maleteachermale teacher_male late_start i.month $controls, vce(cluster class)
estadd local classfe " "
estadd local monthfe " X "
estadd local controls " X "
eststo: xi: qui areg Zmarks male malelate maleteachermale teacher_male late_start, absorb(class) vce(cluster class)
estadd local classfe " X "
estadd local monthfe " "
estadd local controls " "
eststo: xi: qui areg Zmarks male malelate maleteachermale teacher_male late_start i.month, absorb(class) vce(cluster class)
estadd local classfe " X "
estadd local monthfe " X "
estadd local controls " "
eststo: xi: qui areg Zmarks male malelate maleteachermale teacher_male late_start $controls, absorb(class) vce(cluster class)
estadd local classfe " X "
estadd local monthfe " "
estadd local controls " X "
eststo: xi: qui areg Zmarks male malelate maleteachermale teacher_male late_start i.month $controls, absorb(class) vce(cluster class)
estadd local classfe " X "
estadd local monthfe " X "
estadd local controls " X "

label var male "\ \ \ Male"
label var maleteachermale "\ \ \ Male X \\ \hspace{0.3cm} Male Teacher"
label var malelate "\ \ \ Male X \\ \hspace{0.3cm} Late Start"
label var late_start "\ \ \ Late Start"

esttab using "yasenov.tex", ///
    keep(late_start male maleteachermale malelate) replace se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) nonum nonotes ///
	noconstant nogaps scalars("classfe Class FE" "monthfe Month FE" "controls Controls") ///
    mtitles("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)") label
	
